﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WinFormsApp1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            hkmsv1.ImgType = 1;
        }

        private void userControl11_BtnTestClick(object sender, EventArgs e)
        {
          
        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (textBox1.Text == "5")
            {
                hkmsv1.Exposure = (float)Convert.ToDouble(textBox3.Text);
                hkmsv1.Gain = (float)Convert.ToDouble(textBox4.Text);
                hkmsv1.FrameRate = (float)Convert.ToDouble(textBox5.Text);
                aa();
            }
            else if (textBox1.Text == "6")
            {
                aa();
                textBox3.Text= hkmsv1.Exposure.ToString();
                textBox4.Text= hkmsv1.Gain.ToString();
                textBox5.Text= hkmsv1.FrameRate.ToString();
            }
            else if (textBox1.Text == "7")
            {
                aa();
            }
            else
            {
                aa();
                if (textBox1.Text=="1" && hkmsv1.DeviceList.Count() > 0)
                {
                    listBox1.Items.Clear();
                    foreach (var item in hkmsv1.DeviceList)
                    {
                        listBox1.Items.Add(item);
                    }
                }
            }
        }

        private void aa()
        {
            hkmsv1.TagCMD = textBox1.Text;
            System.Threading.Thread.Sleep(1000);
            textBox2.Text = hkmsv1.TagFlag.ToString();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            textBox1.Text = "6";//读取
            button1_Click(null, null);
        }

        private void button3_Click(object sender, EventArgs e)
        {
            textBox1.Text = "5";//设置
            button1_Click(null, null);
        }

        private void button4_Click(object sender, EventArgs e)
        {
            textBox1.Text = "7";
            button1_Click(null, null);
        }

        private void button5_Click(object sender, EventArgs e)
        {
            textBox1.Text = "2";
            button1_Click(null, null);
            textBox1.Text = "3";
            button1_Click(null, null);
        }

        private void button6_Click(object sender, EventArgs e)
        {
            textBox1.Text = "8";
            button1_Click(null, null);
        }
    }
}
